package top.kaoshanji.p2ch15b;

/**
 * 代码清单-p2ch15b-464页a：线程处于RUNNABLE状态对中断的反应
 * author kaoshanji
 * ^_^
 * create time 2025/2/24 18:51
 */
public class InterruptRunnableDemo extends Thread {

    @Override
    public void run() {
        while (!Thread.currentThread().isInterrupted()) {
            // ... 单次循环代码
        }
        System.out.println("done ");
    }

    public static void main(String[] args) throws InterruptedException {
        Thread thread = new InterruptRunnableDemo();
        thread.start();

        Thread.sleep(1000);

        thread.interrupt();
    }

}
